#include"sqlite.hpp"
#include<cassert>

int select_stu_callback(void* arg,int col_count,char** result,char** fields_name){
    std::vector<std::string>* arry = (std::vector<std::string>*)arg;
    arry->push_back(result[0]);
    return 0;
}

int main(){
    SqliteHelper sq("./test.db");

    assert(sq.open());
    std::string sql1 = "create table if not exists student(sn int32 primary key , name varchar(32) , age int);";
    assert(sq.exec(sql1,nullptr,nullptr));
    std::string sql2 = "insert into student values (1, '小明', 18), (2, '小黑', 19), (3, '小红', 18);";
    assert(sq.exec(sql2,nullptr,nullptr));
    std::string sql3 = "update student set name='江小明'where sn=1";
    assert(sq.exec(sql3,nullptr,nullptr));
    std::string sql4 = "delete from student where sn='3'";
    assert(sq.exec(sql4,nullptr,nullptr));

    std::string sql5 = "select name from student;";
    std::vector<std::string>arry;
    sq.exec(sql5,select_stu_callback,&arry);
    assert(sq.close());

    return 0;
}